package com.tgy.controller;

import com.tgy.entity.Books;
import com.tgy.service.BooksService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

/***
 * @ClassName: TestController
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 14:17 2021/12/22
 * @version : V1.0
 */
@RestController
public class TestController {
    @RequestMapping("a1")
    @ResponseBody
    public String t1(String name){
        System.out.println(name);
        return "666"+name;
    }

    @Resource
    private BooksService booksService;
    @RequestMapping("a2")
    public List<Books> getAll() {
        return booksService.getAll();
    }

    @RequestMapping("a3")
    public String  login(String name,String pwd) {
        String msg = "";
        //模拟数据库中存在数据
        if (name!=null){
            if ("admin".equals(name)){
                msg = "OK";
            }else {
                msg = "用户名输入错误";
            }
        }
        if (pwd!=null){
            if ("123456".equals(pwd)){
                msg = "OK";
            }else {
                msg = "密码输入有误";
            }
        }
        return msg; //由于@RestController注解，将msg转成json格式返回
    }
}
